home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!netnews
- From: judgemi@ix.netcom.com (Michael Judge)
- Newsgroups: comp.lang.c++
- Subject: Re: What's so bad about global variables?
- Date: 15 Feb 1996 13:29:55 GMT
- Organization: TSI
- Message-ID: <4fvcgj$eva@cloner2.ix.netcom.com>
- References: <4fjtga$a8s@ias2.ichange.com>
- NNTP-Posting-Host: ix-bst-ma2-11.ix.netcom.com
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=US-ASCII
- X-NETCOM-Date: Thu Feb 15 5:29:55 AM PST 1996
- X-Newsreader: WinVN 0.99.7
-
- In article <4fjtga$a8s@ias2.ichange.com>, jshute@connect.reach.net says...
- >
- >
- > Why do programmers treat like global variables as if they are the
- >single most evil thing you can possibly do in a C program?
- >
- > In reading through a programming book, I came across a program that
- >needed to use random numbers. Instead of just using the C library
- >functions, they developed their own class for random numbers. Their
- >justification - srand and rand will result in the creation of a global
- >variable, and all good programmers know that global variables must be
- >avoided.
- >
- > To me, this seems a little silly. I don't see what the problem is
- >with global variables, especially when they can be hidden using
- >static. Is it really that important to avoid global variables?
- >
-
- globals are not "thread safe". They also cause problems when reusing code.
-
- judgemi@ix.netcom.com
-
-